package com.yf.course.modules.course.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yf.base.api.api.ApiRest;
import com.yf.base.api.api.controller.BaseController;
import com.yf.base.api.api.dto.PagingReqDTO;
import com.yf.course.modules.course.dto.CourseFileLearnDTO;
import com.yf.course.modules.course.dto.CourseLearnDailyDTO;
import com.yf.course.modules.course.dto.response.CourseFileLearnRespDTO;
import com.yf.course.modules.course.service.CourseFileLearnService;
import com.yf.course.modules.course.service.CourseLearnDailyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
* <p>
* 课件学习控制器
* </p>
*
* @author 聪明笨狗
* @since 2020-12-17 11:28
*/
@Api(tags={"课件学习"})
@RestController
@RequestMapping("/api/course/file/learn")
public class CourseLearnController extends BaseController {

    @Autowired
    private CourseFileLearnService baseService;

    @Autowired
    private CourseLearnDailyService courseLearnDailyService;


    /**
    * 分页查找
    * @param reqDTO
    * @return
    */
    @ApiOperation(value = "分页查找")
    @PostMapping("/paging")
    public ApiRest<IPage<CourseFileLearnRespDTO>> paging(@RequestBody PagingReqDTO<CourseFileLearnDTO> reqDTO) {
        //分页查询并转换
        IPage<CourseFileLearnRespDTO> page = baseService.paging(reqDTO);
        return super.success(page);
    }

    /**
     * 每日学习日志
     * @param reqDTO
     * @return
     */
    @ApiOperation(value = "每日学习日志")
    @PostMapping("/daily-paging")
    public ApiRest<IPage<CourseLearnDailyDTO>> dailyPaging(@RequestBody PagingReqDTO<CourseLearnDailyDTO> reqDTO) {

        //分页查询并转换
        IPage<CourseLearnDailyDTO> page = courseLearnDailyService.paging(reqDTO);

        return super.success(page);
    }
}
